package com.cy.pj.sys.controller;

import com.cy.pj.sys.common.util.PageUtil;
import com.cy.pj.sys.pojo.SysLog;
import com.cy.pj.sys.service.SysLogService;
import com.cy.pj.sys.web.pojo.JsonResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/log/")
public class SysLogController {
    @Autowired
    private SysLogService sysLogService;

    @GetMapping("{id}")
    public JsonResult doFindById(@PathVariable Long id) {
        return new JsonResult(sysLogService.findById(id));
    }

    @GetMapping
    public JsonResult doFindLogs(SysLog syslog) {
        PageInfo<SysLog> pageInfo = PageUtil.startPage().doSelectPageInfo(()->
                sysLogService.findLogs(syslog));
        return new JsonResult(pageInfo);
    }

    @DeleteMapping("{id}")
    public JsonResult doDeleteById(@PathVariable Long...id) {
        sysLogService.deleteById(id);
        return new JsonResult("delete ok");
    }
}
